//
//  BaseTableViewController.m
//  OverseasOnlineShopping
//
//  Created by 唐先才 on 16/3/6.
//  Copyright © 2016年 唐先才. All rights reserved.
//

#import "BaseTableViewController.h"
#import "BaseTableViewCell.h"
#import "OverseasOnlineShopping-Swift.h"

@interface BaseTableViewController ()

@end

@implementation BaseTableViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.baseDataArray = [[NSMutableArray alloc] init];
    [self createTableView];
}

- (void)createTableView {
    self.baseTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.baseTableView.dataSource = self;
    self.baseTableView.delegate = self;
    self.baseTableView.rowHeight = 130;
    self.baseTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    [self.view addSubview:self.baseTableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.baseDataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [BaseTableViewCell configCellWith:tableView indexPath:indexPath dataArray:self.baseDataArray];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    TxcModel *model = self.baseDataArray[indexPath.row];
    DetailViewController *detailVC = [[DetailViewController alloc] init];
    NSString *infoID = [NSString stringWithFormat:@"%@", model.InfoID];
    detailVC.goodsID = infoID;
    detailVC.parameters = @{@"infoID": infoID};
    detailVC.pic_url = model.MainImage;
    [self.navigationController pushViewController:detailVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
